package com.ttx.proxy;

import org.junit.Test;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import java.net.InetSocketAddress;
import java.net.Proxy;

/**
 * @author TimFruit
 * @date 2019/8/8 12:09
 */

public class Client {


    @Test
    public void testTemplate(){
        SimpleClientHttpRequestFactory factory=new SimpleClientHttpRequestFactory();
        factory.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 9999)));
        RestTemplate restTemplate=new RestTemplate();
        restTemplate.setRequestFactory(factory);
        
//        ResponseEntity<String> responseEntity=restTemplate.getForEntity("http://127.0.0.1:8080/", String.class);
        ResponseEntity<String> responseEntity=restTemplate.getForEntity("http://tool.chinaz.com/pagestatus/", String.class);
        
        System.out.println(responseEntity.getBody());
    }
}
